package com.gss.autotools.control;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ScreenCoordinatesDisplay extends JFrame {
    private JLabel coordinatesLabel;

    public ScreenCoordinatesDisplay() {
        setTitle("Screen Coordinates Display");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(500, 500);
        setLocationRelativeTo(null);

        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));

        coordinatesLabel = new JLabel();
        coordinatesLabel.setFont(new Font("Arial", Font.BOLD, 20));
        panel.add(coordinatesLabel);

        addMouseListener(new MouseAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                Point point = e.getLocationOnScreen();
                coordinatesLabel.setText("Coordinates: (" + point.x + ", " + point.y + ")");
            }
        });

        getContentPane().add(panel);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            ScreenCoordinatesDisplay display = new ScreenCoordinatesDisplay();
            display.setVisible(true);
        });
    }
}
